/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAOHibernate;

import DAO.PreTreinoDAO;
import entidade.PreTreino;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author Thais
 */
public class PreTreinoDAOHibernate implements PreTreinoDAO {

    @Override
    public PreTreino buscarPreTreino(Long idPreTreino) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProjetoFinalClientePU");
        EntityManager em = emf.createEntityManager();
        Query buscar = em.createQuery("Select object(c) from PreTreino as c where c.idPreTreino = ?1");
        buscar.setParameter(1, idPreTreino);
        PreTreino t = (PreTreino) buscar.getSingleResult();
        return t;
    }
}
